/**
 * manageAuth
 *
 * @author glory.xu
 */

const excludeUrl = [ '/manage/login', '/manage/doLogin' ];

export default () => {
  const manageAuth = async (ctx, next) => {
    if (excludeUrl.includes(ctx.request.url)) {
      return await next();
    }


    const username = ctx.session.username;
    console.log('manageAuth----' + username + '--' + ctx.request.url);
    if (username) {
      await next();
      return;
    }
    ctx.redirect('/manage/login');

  };
  return manageAuth;
};

